//
//  PictureCollectionViewCell.m
//  BeanTrip
//
//  Created by dlios on 15-7-11.
//  Copyright (c) 2015年 PandaGroup. All rights reserved.
//

#import "PictureCollectionViewCell.h"
#define WIDTH ([UIScreen mainScreen].bounds.size.width/375)
#define HEIGH ([UIScreen mainScreen].bounds.size.height/667)
@implementation PictureCollectionViewCell
- (void)dealloc
{
    [_dinnerData release];
    [_imageV release];
    [_label release];
    [_label1 release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self getNewView];
    }
    return self;
}
- (void)getNewView
{
    
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(0 , 0 - 10, 375 * WIDTH, 330 * HEIGH)];
    //self.imageV.backgroundColor = [UIColor blackColor];
    [self addSubview:self.imageV];


    
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(20 * WIDTH, 350 * HEIGH - 10, 335 * WIDTH, 90 * HEIGH)];
    self.label.numberOfLines = 0;
    self.label.lineBreakMode = NSLineBreakByWordWrapping;
    self.label.textColor = [UIColor whiteColor];
    self.label.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:16];
    self.label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.label];
    
    self.label1 = [[UILabel alloc] initWithFrame:CGRectMake(20 * WIDTH, 450 * HEIGH - 20, 335 * WIDTH, 30 * HEIGH)];
    self.label1.textColor = [UIColor whiteColor];
    self.label1.font = [UIFont fontWithName:@"Helvetica-BoldOblique" size:16];
    [self addSubview:self.label1];
   
    
}

-(void)setDinnerData:(DetailPicturesModel *)dinnerData
{
    
    if (_dinnerData != dinnerData) {
        _dinnerData = dinnerData;
    }
    
    NSString *urlStr = _dinnerData.photo;
    NSString *urlEconde = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:urlEconde];
    [self.imageV sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"BeanTrip.png"]];
    self.label.text = _dinnerData.text;
    self.label1.text = _dinnerData.local_time;
}

@end
